import request from '../utils/request'

export function uploadFile(file, code) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: `/file/upload/${code}`,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function downloadFile(code, fileName,password) {
  return request({
    url: `/file/download/${code}/${fileName}`,
    method: 'get',
    responseType: 'blob',
    timeout: 300000,  // Increase timeout for large files
    params: {
      password:password 
    }
  })
}

export function listFiles(code) {
  return request({
    url: `/file/list/${code}`,
    method: 'get'
  })
}

export function deleteFile(code, fileName) {
  return request({
    url: `/file/delete/${code}/${fileName}`,
    method: 'delete'
  })
}